package com.hjm.project.clientImg.clientImg.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.hjm.framework.aspectj.lang.annotation.Log;
import com.hjm.framework.aspectj.lang.enums.BusinessType;
import com.hjm.project.clientImg.clientImg.domain.ClientImg;
import com.hjm.project.clientImg.clientImg.service.IClientImgService;
import com.hjm.framework.web.controller.BaseController;
import com.hjm.framework.web.domain.AjaxResult;
import com.hjm.common.utils.poi.ExcelUtil;
import com.hjm.framework.web.page.TableDataInfo;

/**
 * 商户/服务商图片资料Controller
 * 
 * @author clientImg
 * @date 2020-11-24
 */
@Controller
@RequestMapping("/clientImg/clientImg")
public class ClientImgController extends BaseController
{
    private String prefix = "clientImg/clientImg";

    @Autowired
    private IClientImgService clientImgService;

    @RequiresPermissions("clientImg:clientImg:view")
    @GetMapping()
    public String clientImg()
    {
        return prefix + "/clientImg";
    }

    /**
     * 查询商户/服务商图片资料列表
     */
    @RequiresPermissions("clientImg:clientImg:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(ClientImg clientImg)
    {
        startPage();
        List<ClientImg> list = clientImgService.selectclientImgList(clientImg);
        return getDataTable(list);
    }

    /**
     * 导出商户/服务商图片资料列表
     */
    @RequiresPermissions("clientImg:clientImg:export")
    @Log(title = "商户/服务商图片资料", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(ClientImg clientImg)
    {
        List<ClientImg> list = clientImgService.selectclientImgList(clientImg);
        ExcelUtil<ClientImg> util = new ExcelUtil<ClientImg>(ClientImg.class);
        return util.exportExcel(list, "clientImg");
    }

    /**
     * 新增商户/服务商图片资料
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存商户/服务商图片资料
     */
    @RequiresPermissions("clientImg:clientImg:add")
    @Log(title = "商户/服务商图片资料", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(ClientImg clientImg)
    {
        return toAjax(clientImgService.insertclientImg(clientImg));
    }

    /**
     * 修改商户/服务商图片资料
     */
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        ClientImg clientImg = clientImgService.selectclientImgById(id);
        mmap.put("clientImg", clientImg);
        return prefix + "/edit";
    }

    /**
     * 修改保存商户/服务商图片资料
     */
    @RequiresPermissions("clientImg:clientImg:edit")
    @Log(title = "商户/服务商图片资料", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(ClientImg clientImg)
    {
        return toAjax(clientImgService.updateclientImg(clientImg));
    }

    /**
     * 删除商户/服务商图片资料
     */
    @RequiresPermissions("clientImg:clientImg:remove")
    @Log(title = "商户/服务商图片资料", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(clientImgService.deleteclientImgByIds(ids));
    }
}
